<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>面向对象</title>
</head>
<body>

</body>
<script>

    /**
     * 创建对象的方式
     * 1. 字面量
     *       1. 灵活
     *       2. 全新
     * 2.面向对象
    * */
    /*var employee = {
        name:'Mary',
        age:'34'
    }

    alert(employee.name)*/

    function Employee(name,age,gender) {
        this.name=name;
        this.age=age;
        this.gender=gender;
        this.sayHello=function () {
            alert("I am "+ this.name);
        }
    }

    var employee1 = new Employee('Mat',23,'male');// {name:'Mat'....   }
    var employee2 = new Employee('Lee',23);// {name:'Mat'....   }

   // alert(employee1.age);
   // alert(employee2.name);
 //   alert(employee2.gender);
    employee2.sayHello();


</script>
</html>